<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../node_modules/lodash/lodash.js"></script>
</head>
<body>
  <p>count值为：<span>???</span></p>
  <button>点击count加1</button>
  <script>
    // 测试节流
    const span = document.querySelector('span')
    const btn = document.querySelector('button')
    let count = 0
    // _.throttle 节流函数
    // 作用：把频繁的触发变为少量触发
    // 比如 王者 平a 也是用到节流 轮播图也是
    btn.onclick = _.throttle(function(){
      count++
      span.innerHTML = count
      console.log('点击触发了');
    },1000)
  </script>
</body>
</html>